let utils = require('./util.js');
function doJump(type, id, pageType,pageId, url) {
	console.log(type, id, pageType,pageId, url)
  if ("classfiy" == type) {
    uni.navigateTo({
      url: '/pages/goodsList/goodsList?classifyId=' + id,
    })
  } else if ("goods" == type) {
    uni.navigateTo({
      url: '/subPackages/mall/pages/goods/goods?goodsId=' + id,
    })
  } else if ("entry" == type) {
    if ("1" == id) {
      utils.switchTabLoc('/subPackages/mall/pages/cart/cart');
    } else if ("2" == id) {
      uni.reLaunch({ url: '/pages/my/my' })
    } else if ("3" == id) {
      uni.navigateTo({ url: '/minorPkg/pages/pointCenter/pointCenter' })
    } else if ("4" == id) {
      uni.navigateTo({ url: '/minorPkg/pages/couponCenter/couponCenter' })
    } else if ("5" == id) {
      uni.navigateTo({ url: '/subPackages/kernelPkg/pages/address/address' })
    } else if ("6" == id) {
      uni.navigateTo({ url: '/minorPkg/pages/myCollect/myCollect' })
    } else if ("7" == id) {
      uni.navigateTo({ url: '/pages/merEntry/merEntry' })
    } else if ("8" == id) {
      uni.navigateTo({ url: '/minorPkg/pages/point/point' })
    } else if ("9" == id) {
      uni.navigateTo({ url: '/minorPkg/pages/coupon/coupon' })
    } else if ("10" == id) {
      uni.navigateTo({ url: '/subPackages/mall/pages/goodsList/goodsList' })
    }else if("11" == id){
      uni.navigateTo({
        url: '/marketingPkg/pages/park/parkIndex'
      })
    }
  } else if ("tag" == type) {
    uni.navigateTo({
      url: '/subPackages/minorPkg/pages/store/storeGoods?tagId=' + id
    })
  } else if ("messageType" == type) {
    uni.navigateTo({
      url: '/subPackages/minorPkg/pages/message/message?typeId=' + id
    })
  } else if ("message" == type) {
    uni.navigateTo({
      // url: '/minorPkg/pages/messageDetail/messageDetail'
      url: '/subPackages/minorPkg/pages/messageDetail/messageDetail?id=' + id
    })
  } else if ("diypage" == type) {
    uni.navigateTo({
      url: '/pages/diypage/diypage?pageId=' + id + "&type=" + pageType
    })
  } else if ("activity1" == type) {
    uni.navigateTo({
      // url: '/marketingPkg/pages/activity/wheel?id=' + id
      url: '/subPackages/lottery/pages/wheel/wheel?id=' + id
    })
  } else if ("activity2" == type) {
    uni.navigateTo({
      // url: '/marketingPkg/pages/activity/goldenEgg?id=' + id
      url: '/subPackages/lottery/pages/goldenEgg/goldenEgg?id=' + id
    })
  } else if ("activity3" == type) {
    uni.navigateTo({
      // url: '/marketingPkg/pages/activity/scratchCard?id=' + id
      url: '/subPackages/lottery/pages/scratch/scratch?id=' + id
    })
  } else if ("activity4" == type) {
    uni.navigateTo({
      // url: '/marketingPkg/pages/activity/constellation?id=' + id
      url: '/subPackages/lottery/pages/constellation/constellation?id=' + id
    })
  } else if ("bargain" == type) {
    uni.navigateTo({
      url: '/subPackages/mall/pages/newBargain/newBargain?id=' + id
    })
  } else if ("secondKill" == type) {
    uni.navigateTo({
      url: '/marketingPkg/pages/seckill/seckill'
    })
  } else if ("pointToCoupon" == type) {
    uni.navigateTo({
      url: '/subPackages/pointMallPkg/pages/pointToCouponDetail/pointToCouponDetail?id=' + id
    })
  } else if ("pointToGoods" == type) {
    uni.navigateTo({
      url: '/subPackages/pointMallPkg/pages/pointToGoodsDetail/pointToGoodsDetail?exchangeId=' + id
    })
  } else if ("discount" == type) {
    uni.navigateTo({
      url: '/marketingPkg/pages/limitTimeDiscount/limitTimeDiscount?discountId=' + id
    })
  } else if ("sign" == type) {
    uni.navigateTo({
      url: '/minorPkg/pages/merchantInfo/merchantInfo?merchantId=' + id
    })
  } else if ("seckill" == type) {
    var ids = id.split('-');
    uni.navigateTo({
      url: '/subPackages/mall/pages/seckillGoodsDetail/seckillGoodsDetail?seckillId=' + ids[0] + '&goodsId=' + ids[1]
    })
  } else if ("seckillList" == type) {
    uni.navigateTo({
      url: '/subPackages/mall/pages/seckill/seckill'
    })
  } else if ("bargainList" == type) {
    uni.navigateTo({
      url: '/subPackages/mall/pages/bargainList/bargainList?pageId='+pageId
    })
  } else if ("collage" == type) {
    var ids = id.split('-');
    uni.navigateTo({
      url: '/subPackages/mall/pages/groupbuyDetail/groupbuyDetail?groupbuyId=' + ids[0] + '&goodsId=' + ids[1]
    })
  } else if ("collageList" == type) {
    uni.navigateTo({
      url: '/subPackages/mall/pages/groupbuyList/groupbuyList'
    })
  } else if ("liveBroadCast" == type) {
    var ids = id.split('-')[0];
    var roomId = parseInt(ids);
    let customParams = { path: 'pages/diyhome/diyhome'}; 
    uni.navigateTo({
      url: 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + roomId+'&custom_params='+encodeURIComponent(JSON.stringify(customParams))
    })
  } else if ("liveBroadCastList" == type) {
    var extConfig = uni.getExtConfigSync();
    var tabBarIcon = extConfig.tabBarIcon;
    if(undefined !=tabBarIcon){
      var haveLiveBroadCastTabBar=false;
      for(let i=0; i<tabBarIcon.length;i++){
        if("zhibo"==tabBarIcon[i]){
          haveLiveBroadCastTabBar=true;
        }
      }
      if(haveLiveBroadCastTabBar){
        uni.reLaunch({
          url: '/pages/liveBroadCast/liveBroadCastList',
        })
      }else{
        uni.navigateTo({
          url: '/pages/liveBroadCast/liveBroadCastList',
        })
      }
    }else{
      uni.navigateTo({
        url: '/pages/liveBroadCast/liveBroadCastList',
      })
    }
  } else if(type == 'pageDictionary0') {
    uni.navigateTo({
		url,
		fail() {
			uni.reLaunch({ url })
		}
    })
  } else if(type == 'pageDictionary1' || type == 'paper') {
    uni.navigateTo({
      url: '/pages/outlink/outlink?outlink=' + url,
    })
  } else if(type == 'pageDictionary2') {
	  console.log(url)
    let urlArr = url.split(",");
    uni.navigateTo({
      url: urlArr[1],
      fail() {
        uni.reLaunch({
          url: urlArr[1]
        })
      }
    })
  }
}

module.exports = {
  doJump
}